package com.littleken.foodieCommon.enums;

/**
 * @Description: 支付方式 枚举
 */
public enum PayMethodEnum {

	WEIXIN(1, "微信"),
	ALIPAY(2, "支付宝");

	private Integer code;
	private String desc;

	PayMethodEnum(Integer code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	/**
	 * 通过 CODE 获取 DESC
	 * @param code
	 * @return
	 */
	public static String getDescByCode(Integer code) {
		for (PayMethodEnum payMethod : PayMethodEnum.values()) {
			if (payMethod.code.equals(code)) {
				return payMethod.desc;
			}
		}
		return null;
	}

	/**
	 * 通过 DESC 获取 CODE
	 * @param desc
	 * @return
	 */
	public static Integer getCodeByDesc(String desc) {
		for (PayMethodEnum payMethod : PayMethodEnum.values()) {
			if (payMethod.desc.equals(desc)) {
				return payMethod.code;
			}
		}
		return null;
	}

	/**
	 * 通过 CODE 获取 Enum
	 * @param code
	 * @return
	 */
	public static PayMethodEnum getEnumByCode(Integer code) {
		for (PayMethodEnum payMethod : PayMethodEnum.values()) {
			if (payMethod.code.equals(code)) {
				return payMethod;
			}
		}
		return null;
	}
}
